package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.PropertyPadBotDeliveryTaskDTO;
import com.itlong.cloud.POJO.VO.property.PropertyDeliveryTaskGetPageVO;
import com.itlong.cloud.project.property.IPropertyDeliveryTaskServiceClient;
import com.itlong.cloud.property.service.IPropertyDeliveryTaskService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      机器人派送任务接口实现类
 * </desc>
 *
 * @createDate 2021/1/7
 **/
@RestController
public class PropertyDeliveryTaskServiceResource implements IPropertyDeliveryTaskServiceClient {


    @Autowired
    private IPropertyDeliveryTaskService iPropertyDeliveryTaskService;
    /**
     * <desc>
     *      获取目标点列表
     * </desc>
     *
     * @return 目标点信息
     * @Author Zhu.yj
     * @createDate  2021/1/8
     */
    @Override
    @PostMapping("/app//h5/padbot/getTargetPointList")
    public List<Map<String, Object>> getTargetPointList(@RequestParam(value = "phoneNum", required = false) String phoneNum) throws Exception {
        return iPropertyDeliveryTaskService.getTargetPointList(phoneNum);
    }

    /**
     * <desc>
     *      获取配送任务分页列表
     * </desc>
     *
     * @param deliveryTaskDTO 配送任务参数DTO
     * @return 配送任务分页列表
     * @Author Zhu.yj
     * @createDate  2021/1/12
     */
    @Override
    @PostMapping("/property/robotControl/deliveryTask/getPage")
    public Page<PropertyDeliveryTaskGetPageVO> getPage(@RequestBody PropertyPadBotDeliveryTaskDTO deliveryTaskDTO) throws Exception {
        return iPropertyDeliveryTaskService.getPage(deliveryTaskDTO);
    }

    /**
     * <desc>
     *      修改配送任务状态
     * </desc>
     *
     * @param taskId 回调信息
     * @return
     * @Author Zhu.yj
     * @createDate  2021/1/12
     */
    @Override
    @PostMapping("/foreign/padbot/callback/updateTaskStatus")
    public boolean updateTaskStatus(@RequestParam("taskId") String taskId, @RequestParam("status") String status) throws Exception {
        return iPropertyDeliveryTaskService.updateTaskStatus(taskId, status);
    }

    /**
     * <desc>
     *      回调接收派送任务信息
     * </desc>
     *
     * @param taskJson 派送任务信息
     * @return
     * @Author Zhu.yj
     * @createDate  2021/1/13
     */
    @PostMapping("/foreign/padbot/callback/receiveDeliveryTaskInfo")
    @Override
    public boolean receiveDeliveryTaskInfo(@RequestParam("taskJson") String taskJson) throws Exception {
        return iPropertyDeliveryTaskService.receiveDeliveryTaskInfo(taskJson);
    }

    /**
     * <desc>
     *      根据电话号码获取目标点
     * </desc>
     *
     * @param phoneNumber 电话号码
     * @return
     * @Author Zhu.yj
     * @createDate  2021/1/22
     */
    @Override
    @PostMapping("/app/padbot/delivery/getTargetPointId")
    public String getTargetPointId(@RequestParam("phoneNumber") String phoneNumber) throws Exception {
        return iPropertyDeliveryTaskService.getTargetPointId(phoneNumber);
    }


}
